﻿using LdtJudge.DataEngine.CallInterface.CommHelp;
using LdtJudge.DataEngine.Model.DataModel.DataParseStorage;
using System;
using System.Collections.Generic;
using System.Text;

namespace LdtJudge.DataEngine.Data.DataParseStorage
{
    /// <summary>
    /// 案件实体对应角色
    /// </summary>
    public class DAL_An_anjianshitijuese
    {
        private IFreeSql FreeSql = FreeSQLHelp.GetFreeSQL("Ldt_DataParseStorage");
        /// <summary>
        /// 获取列表
        /// </summary>
        /// <param name="anjid">条件</param>
        /// <returns></returns>
        public List<An_anjianshitijuese> GetList(string anjianshitiid)
        {
            return FreeSql.Select<An_anjianshitijuese>().Where(a => a.Anjianshitiid == anjianshitiid).ToList();
        }

        /// <summary>
        /// 验证是否能存在指定实体角色
        /// </summary>
        /// <param name="anjianshitiid">实体角色ID</param>
        /// <returns></returns>
        public An_anjianshitijuese Exist(string anjianshitiid)
        {
            return FreeSql.Select<An_anjianshitijuese>().Where(a => a.Anjianshitiid == anjianshitiid)?.ToOne();
        }

        /// <summary>
        /// 添加案件中的实体数据
        /// </summary>
        /// <param name="model">案件数据存储模型</param>
        /// <returns></returns>
        public int Insert(An_anjianshitijuese model)
        {
            return FreeSql.Insert<An_anjianshitijuese>(model).ExecuteAffrows();
        }

        /// <summary>
        /// 更新案件中的实体数据
        /// </summary>
        /// <param name="model">案件数据存储模型</param>
        /// <returns></returns>
        public int Update(An_anjianshitijuese model)
        {
            return FreeSql.Update<An_anjianshitijuese>(model).SetSourceIgnore(model, col => col == null).ExecuteAffrows();
        }
    }
}
